home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / os2 / nortutil.zip / src / TaxLaw / index.c next >
C/C++ Source or Header  |  1996-08-28  |  863b  |  30 lines

  1. /***************************************************************************
  2. NAME:           index.c
  3.  
  4. PURPOSE:        return the position of the token in a string
  5.                         K&R, converted to use pointers
  6. ****************************************************************************/
  7. #include <stdio.h>
  8.  
  9. char *index(source, token)
  10. char *source, *token;
  11. {
  12. char *ptsource, *pttoken, *ptmatch;
  13.  
  14.         for(ptsource = source; *ptsource != '\0'; ptsource++)
  15.         {
  16.                 for(ptmatch = ptsource, pttoken = token;
  17.  
  18.                         *pttoken != '\0' &&
  19.                         *ptmatch == *pttoken;
  20.  
  21.                         ptmatch++, pttoken++)
  22.  
  23.                         ;
  24.                 
  25.                 if(*pttoken == '\0')
  26.                         return ptsource;
  27.         }
  28.         return (char *)NULL;
  29. }
  30.